<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        class person{
            constructor(name, age)
            {
                this.name = name;
                this.age = age;
            }
        }

        const personArr = [
            new person("小王", 18),
            new person("小张", 19),
            new person("小李", 20),
            new person("小赵", 17),
            new person("小孙", 18)
        ]

        function filter(arr, cb)
        {
            const newArr = [];

            for (let i = 0; i < arr.length; i++) 
            {
                if (cb(arr[i]))
                {
                    newArr.push(arr[i]);
                }
            };

            return newArr;
        }

        result = filter(personArr, x => x.age > 19);
        console.log(result);
    </script>
</head>
<body>
    
</body>
</html>